<?php

/**
 * Subclass for representing a row from the 'workfu_user' table.
 *
 * 
 *
 * @package lib.model
 */ 
class User extends BaseUser
{

 public function getFullName()
 {
 
 $first = $this->getFirstName();
 $last = $this->getLastName();
 
 return $first.' '.$last;
 
 }
 
 	public function setPassword($password)
	{
		$salt = md5(rand(100000, 999999).$this->getNickname().$this->getEmail());
		$this->setSalt($salt);
		$this->setPasswordSha1(sha1($salt.$password));
	}
	
public function selectUserState($state)
 {
  
 switch($state) {
	case "AL": return 'selected'; break;
	case "AK": return 'selected'; break;
	case "AZ": return 'selected'; break;
	case "AR": return 'selected'; break;
	case "CA": return 'selected'; break;
	case "CO": return 'selected'; break;
	case "CT": return 'selected'; break;
	case "DE": return 'selected'; break;
	case "DC": return 'selected'; break;
	case "FL": return 'selected'; break;
	case "GA": return 'selected'; break;
	case "HI": return 'selected'; break;
	case "ID": return 'selected'; break;
	case "IL": return 'selected'; break;
	case "IN": return 'selected'; break;
	case "IA": return 'selected'; break;
	case "KS": return 'selected'; break;
	case "KY": return 'selected'; break;
	case "LA": return 'selected'; break;
	case "ME": return 'selected'; break;
	case "MD": return 'selected'; break;
	case "MA": return 'selected'; break;
	case "MI": return 'selected'; break;
	case "MN": return 'selected'; break;
	case "MS": return 'selected'; break;
	case "MO": return 'selected'; break;
	case "MT": return 'selected'; break;
	case "NE": return 'selected'; break;
	case "NV": return 'selected'; break;
	case "NH": return 'selected'; break;
	case "NJ": return 'selected'; break;
	case "NM": return 'selected'; break;
	case "NY": return 'selected'; break;
	case "NC": return 'selected'; break;
	case "ND": return 'selected'; break;
	case "OH": return 'selected'; break;
	case "OK": return 'selected'; break;
	case "OR": return 'selected'; break;
	case "PA": return 'selected'; break;
	case "RI": return 'selected'; break;
	case "SC": return 'selected'; break;
	case "SD": return 'selected'; break;
	case "TN": return 'selected'; break;
	case "TX": return 'selected'; break;
	case "UT": return 'selected'; break;
	case "VT": return 'selected'; break;
	case "VA": return 'selected'; break;
	case "WA": return 'selected'; break;
	case "WV": return 'selected'; break;
	case "WI": return 'selected'; break;
	case "WY": return 'selected'; break;
	}

 
 
 }	

 public function getUserState()
 {
 
 $state = $this->getState();
 
 switch($state) {
	case "AL": echo 'Alabama'; break;
	case "AK": echo 'Alaska'; break;
	case "AZ": echo 'Arizona'; break;
	case "AR": echo 'Arkansas'; break;
	case "CA": echo 'California'; break;
	case "CO": echo 'Colorado'; break;
	case "CT": echo 'Connecticut'; break;
	case "DE": echo 'Delaware'; break;
	case "DC": echo 'District of Columbia'; break;
	case "FL": echo 'Florida'; break;
	case "GA": echo 'Georgia'; break;
	case "HI": echo 'Hawaii'; break;
	case "ID": echo 'Idaho'; break;
	case "IL": echo 'Illinois'; break;
	case "IN": echo 'Indiana'; break;
	case "IA": echo 'Iowa'; break;
	case "KS": echo 'Kansas'; break;
	case "KY": echo 'Kentucky'; break;
	case "LA": echo 'Louisiana'; break;
	case "ME": echo 'Maine'; break;
	case "MD": echo 'Maryland'; break;
	case "MA": echo 'Massachusetts'; break;
	case "MI": echo 'Michigan'; break;
	case "MN": echo 'Minnesota'; break;
	case "MS": echo 'Mississippi'; break;
	case "MO": echo 'Missouri'; break;
	case "MT": echo 'Montana'; break;
	case "NE": echo 'Nebraska'; break;
	case "NV": echo 'Nevada'; break;
	case "NH": echo 'New Hampshire'; break;
	case "NJ": echo 'New Jersey'; break;
	case "NM": echo 'New Mexico'; break;
	case "NY": echo 'New York'; break;
	case "NC": echo 'North Carolina'; break;
	case "ND": echo 'North Dakota'; break;
	case "OH": echo 'Ohio'; break;
	case "OK": echo 'Oklahoma'; break;
	case "OR": echo 'Oregon'; break;
	case "PA": echo 'Pennsylvania'; break;
	case "RI": echo 'Rhode Island'; break;
	case "SC": echo 'South Carolina'; break;
	case "SD": echo 'South Dakota'; break;
	case "TN": echo 'Tennessee'; break;
	case "TX": echo 'Texas'; break;
	case "UT": echo 'Utah'; break;
	case "VT": echo 'Vermont'; break;
	case "VA": echo 'Virginia'; break;
	case "WA": echo 'Washington'; break;
	case "WV": echo 'West Virginia'; break;
	case "WI": echo 'Wisconsin'; break;
	case "WY": echo 'Wyoming'; break;
	}

 
 
 }
	
	
 public function checkFbUser()
 {
 $c = new Criteria();
 $c->add(user2facebookPeer::USER_ID,$this->getId());
 $checkFbUser = user2facebookPeer::doSelectOne($c);
 
 if ($checkFbUser) {
 
 return true;
 
 } else {
 
 return false;
 
 }
 
 
 
 }


 public function createFbBadge() {
 
 
 require_once('fbconnect/facebookclient/facebook.php'); 
	/* initialize the facebook API with your application API Key and Secret */ 
				
	$appapikey = 'd8e8e7f3873dcc631dfe72df510e97f2';
	$appsecret = 'b31af758e13c88e5f4f537f79525d16c';
	$facebook = new Facebook($appapikey, $appsecret);
	$fbuid = $facebook->get_loggedin_user();

	$user_details=$facebook->api_client->users_getInfo($fbuid, array('last_name','first_name','is_app_user','pic'));
				
	$data['uid']=$user_details[0]['uid'];
	$data['first_name']=$user_details[0]['first_name']; 
	$data['last_name']=$user_details[0]['last_name'];
	$data['isuser']=$user_details[0]['is_app_user'];
 	$data['picurl']=$user_details[0]['pic']; 	

 
 return '<a href="http://www.facebook.com/people/'.$data['first_name'].'-'.$data['last_name'].'/503274069" title="'.$data['first_name'].' '.$data['last_name'].'\'s Facebook profile" target=_TOP><img src="'.$data['picurl'].'" border=0 alt="'.$data['first_name'].' '.$data['last_name'].'\'s Facebook profile"></a>';
 
 
 }
	

}
